package com.dk.utils;

import com.dk.entity.dos.ClassInfo;
import com.dk.entity.dos.UserDo;
import com.dk.entity.dto.StudentDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * Description:复杂的关系映射
 *
 * @author WangDk
 * @date:2021/10/12 13:37
 */
@Mapper
public interface StudentConverter {
    StudentConverter INSTANCE = Mappers.getMapper(StudentConverter.class);
    @Mappings({
            @Mapping(source = "userDo.age", target = "id"),
            @Mapping(source = "userDo.name", target = "name"),
            @Mapping(source = "classInfo.classNumber", target = "classNumber"),
            @Mapping(source = "classInfo.name", target = "className")
    })

    /**
     * 单个转化数据
     */
    StudentDto firstToStudentDto(UserDo userDo, ClassInfo classInfo);
}
